package com.lyf.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @AUTHOR LYF
 * @DATE 2022/5/29
 * @VERSION 1.0
 * @DESC
 */
@RestController
public class LimitController {
    @GetMapping("/test")
    String test(){
        return "test!";
    }

    // 思考热点数据的访问--，限流，熔断都是对路径的进行处理
    @GetMapping("/testHotKey")
    @SentinelResource(value = "testHotKey",blockHandler = "handler")
    String testHotKey(@RequestParam(value = "param",required = false)String p1){
        System.out.println(p1);
        return "hello";
    }
    public String handler(String p1, BlockException e){
        return "error";
    }

}
